﻿using SD.Infrastructure.AppServiceBase;
using SD.Infrastructure.DTOBase;
using SlamDunk.MES.IAppService.DTOs.Inputs;
using SlamDunk.MES.IAppService.DTOs.Outputs.AcquisitionContext;
using System;
using System.Collections.Generic;
using System.ServiceModel;

namespace SlamDunk.MES.IAppService.Interfaces
{
    /// <summary>
    /// 数据采集服务契约接口
    /// </summary>
    [ServiceContract]
    public interface IAcquisitionContract : IApplicationService
    {
        //命令部分

        #region # 创建采集规则 —— void CreateAcquisitionRule(string ruleNo, string ruleName...
        /// <summary>
        /// 创建采集规则
        /// </summary>
        /// <param name="ruleNo">采集规则编号</param>
        /// <param name="ruleName">采集规则名称</param>
        /// <param name="processId">工艺Id</param>
        /// <param name="processSegmentId">工艺段Id</param>
        /// <param name="interval">采集间隔（单位：秒）</param>
        /// <param name="description">描述</param>
        /// <param name="ruleItemParams">采集规则项参数模型集</param>
        [OperationContract]
        void CreateAcquisitionRule(string ruleNo, string ruleName, Guid? processId, Guid? processSegmentId, int interval, string description, IEnumerable<AcquisitionRuleItemParam> ruleItemParams);
        #endregion

        #region # 修改采集规则 —— void UpdateAcquisitionRule(Guid acquisitionRuleId, string ruleNo...
        /// <summary>
        /// 修改采集规则
        /// </summary>
        /// <param name="acquisitionRuleId">采集规则Id</param>
        /// <param name="ruleNo">采集规则编号</param>
        /// <param name="ruleName">采集规则名称</param>
        /// <param name="processId">工艺Id</param>
        /// <param name="processSegmentId">工艺段Id</param>
        /// <param name="interval">采集间隔（单位：秒）</param>
        /// <param name="description">描述</param>
        /// <param name="ruleItemParams">采集规则项参数模型集</param>
        [OperationContract]
        void UpdateAcquisitionRule(Guid acquisitionRuleId, string ruleNo, string ruleName, Guid? processId, Guid? processSegmentId, int interval, string description, IEnumerable<AcquisitionRuleItemParam> ruleItemParams);
        #endregion

        #region # 删除采集规则 —— void RemoveAcquisitionRule(Guid acquisitionRuleId)
        /// <summary>
        /// 删除采集规则
        /// </summary>
        /// <param name="acquisitionRuleId">采集规则Id</param>
        [OperationContract]
        void RemoveAcquisitionRule(Guid acquisitionRuleId);
        #endregion

        #region # 创建采集会话 —— Guid CreateAcquisitionSession(Guid acquisitionRuleId, Guid? processId...
        /// <summary>
        /// 创建采集会话
        /// </summary>
        /// <param name="acquisitionRuleId">采集规则Id</param>
        /// <param name="processId">工艺Id</param>
        /// <param name="processSegmentId">工艺段Id</param>
        /// <param name="executionPlanId">作业计划Id</param>
        /// <param name="workOrderId">工单Id</param>
        /// <returns>采集会话Id</returns>
        [OperationContract]
        Guid CreateAcquisitionSession(Guid acquisitionRuleId, Guid? processId, Guid? processSegmentId, Guid? executionPlanId, Guid? workOrderId);
        #endregion

        #region # 激活采集会话 —— void ActivateAcquisitionSession(Guid acquisitionSessionId)
        /// <summary>
        /// 激活采集会话
        /// </summary>
        /// <param name="acquisitionSessionId">采集会话Id</param>
        [OperationContract]
        void ActivateAcquisitionSession(Guid acquisitionSessionId);
        #endregion

        #region # 关闭采集会话 —— void CloseAcquisitionSession(Guid acquisitionSessionId...
        /// <summary>
        /// 关闭采集会话
        /// </summary>
        /// <param name="acquisitionSessionId">采集会话Id</param>
        /// <param name="reason">关闭原因</param>
        [OperationContract]
        void CloseAcquisitionSession(Guid acquisitionSessionId, string reason);
        #endregion

        #region # 追加采集记录 —— void AppendAcquisitionRecords(Guid acquisitionSessionId...
        /// <summary>
        /// 追加采集记录
        /// </summary>
        /// <param name="acquisitionSessionId">采集会话Id</param>
        /// <param name="recordParams">采集记录参数模型集</param>
        [OperationContract]
        void AppendAcquisitionRecords(Guid acquisitionSessionId, IEnumerable<AcquisitionRecordParam> recordParams);
        #endregion


        //查询部分

        #region # 分页获取采集规则列表 —— PageModel<AcquisitionRuleInfo> GetAcquisitionRulesByPage(string...
        /// <summary>
        /// 分页获取采集规则列表
        /// </summary>
        /// <param name="keywords">关键字</param>
        /// <param name="processId">工艺Id</param>
        /// <param name="processSegmentId">工艺段Id</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页容量</param>
        /// <returns>采集规则列表</returns>
        [OperationContract]
        PageModel<AcquisitionRuleInfo> GetAcquisitionRulesByPage(string keywords, Guid? processId, Guid? processSegmentId, int pageIndex, int pageSize);
        #endregion

        #region # 是否存在工艺段相关采集规则 —— bool ExistsAcquisitionRuleByProcessSegment(Guid processSegmentId)
        /// <summary>
        /// 是否存在工艺段相关采集规则
        /// </summary>
        /// <param name="processSegmentId">工艺段Id</param>
        /// <returns>是否存在</returns>
        [OperationContract]
        bool ExistsAcquisitionRuleByProcessSegment(Guid processSegmentId);
        #endregion

        #region # 获取采集规则项列表 —— IEnumerable<AcquisitionRuleItemInfo> GetAcquisitionRuleItems(...
        /// <summary>
        /// 获取采集规则项列表
        /// </summary>
        /// <param name="acquisitionRuleId">采集规则Id</param>
        /// <returns>采集规则项列表</returns>
        [OperationContract]
        IEnumerable<AcquisitionRuleItemInfo> GetAcquisitionRuleItems(Guid acquisitionRuleId);
        #endregion

        #region # 分页获取采集会话列表 —— PageModel<AcquisitionSessionInfo> GetAcquisitionSessionsByPage(...
        /// <summary>
        /// 分页获取采集会话列表
        /// </summary>
        /// <param name="acquisitionRuleId">采集规则Id</param>
        /// <param name="processId">工艺Id</param>
        /// <param name="processSegmentId">工艺段Id</param>
        /// <param name="executionPlanId">作业计划Id</param>
        /// <param name="workOrderId">工单Id</param>
        /// <param name="active">是否活动</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页容量</param>
        /// <returns>采集会话列表</returns>
        [OperationContract]
        PageModel<AcquisitionSessionInfo> GetAcquisitionSessionsByPage(Guid? acquisitionRuleId, Guid? processId, Guid? processSegmentId, Guid? executionPlanId, Guid? workOrderId, bool? active, DateTime? startTime, DateTime? endTime, int pageIndex, int pageSize);
        #endregion

        #region # 获取采集记录列表 —— IEnumerable<AcquisitionRecordInfo> GetAcquisitionRecords(Guid...
        /// <summary>
        /// 获取采集记录列表
        /// </summary>
        /// <param name="acquisitionSessionId">采集会话Id</param>
        /// <returns>采集记录列表</returns>
        [OperationContract]
        IEnumerable<AcquisitionRecordInfo> GetAcquisitionRecords(Guid acquisitionSessionId);
        #endregion
    }
}
